package com.trkj.dao.jpa;

import java.util.List;

import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import com.trkj.pojos.YzrSupplier;

public interface IYzrSupplierDAO extends CrudRepository<YzrSupplier, String> {
	//分页查询
	@Query("select new YzrSupplier(s.supId,s.supAddress,s.supContext,s.supCredit,"
			+ "s.supDeliveryMode,s.supExplain,s.supFax,s.supKind,s.supName,s.supPayment,"
			+ "s.supPhone) from YzrSupplier s order by s.supId desc")
	public List<YzrSupplier> findAll(Pageable pageable);
	
	//只查询药品供应
	@Query("select s from YzrSupplier s where s.supKind='药品供应'")
	public List<YzrSupplier> findAll2(Pageable pageable);
	
	//根据编号前缀查询出最大的编号
	@Query("select max(s.supId) from YzrSupplier s where s.supId like ?1%")
	public String findID(String a);	
	
	//根据药房名称模糊查询药房
	@Query("select s from YzrSupplier s where s.supName like %?1%")
	public List<YzrSupplier> findBySupNameLike(String name);
	
	//根据药房类型模糊查询药房
	@Query("select s from YzrSupplier s where s.supKind like %?1%")
	public List<YzrSupplier> findBySupKindLike(String kind);
}
